#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fast() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
priority_queue<ll, vector<ll>, greater<ll>> pq;
const ll MOD = 998244353;
const ll N = 2e5 + 10;
ll d[N];
struct tree_edge
{
    ll u, v;
} p[N];
ll init(ll a, ll b, ll c)
{
    a = a + 1, b = b + 1;
    c = c * 3;
    c++;
    return a * b + c;
}
int main()
{
    fast();
    ll m = 1000;
    init(1, 1, m);
    init(2, 2, m);
    ll T = 1;
    for (ll i = 1; i <= m; i++)
    {
        ll x;
        x = 2 * i + 1;
        pq.push(x);
    }
    cin >> T;
    while (T--)
    {
        ll l, r;
        cin >> l >> r;
        if (l == r)
        {
            if (l == 1)
                cout << 0 << "\n";
            else
                cout << "infty" << "\n";
        }
        else
        {
            ll k = r - l;
            ll t = (l - 2) / k;
            ll ans = (l - 1) * (t + 1) - k * t * (t + 1) / 2;
            cout << ans << "\n";
        }
    }
    int qq = 0;
    while (pq.size() != 1)
    {
        ll x = pq.top();
        pq.pop();
        x += pq.top();
        pq.pop();
        qq += x;
        pq.push(x);
    }
    qq = init(3, 4, qq);
    return 0;
}